<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:variable name="cssPath" select="simorg/paths/css" />
	<xsl:variable name="imagePath" select="/simorg/paths/images" />
	<xsl:variable name="rootUrl" select="simorg/paths/rootUrl" />
	
	<xsl:template match="/">
		<html xmlns:html="http://www.w3.org/TR/xhtml1/strict" lang="en-US" >
			<head>
				<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
				<link type="text/css" href="{$cssPath}/custom-theme/jquery-ui-1.8.9.custom.css" rel="Stylesheet"/>
				<link type="text/css" href="{$cssPath}main.css" rel="Stylesheet"/>
				<script type="text/javascript" src="http://localhost:8091/simorg/js/jquery-1.4.4.min.js"/>
				<script type="text/javascript" src="http://localhost:8091/simorg/js/jquery-ui-1.8.9.custom.min.js"></script>
				
				<script type="text/javascript">
					$(document).ready(function(){
						$("#batchEnroll").css("height", "150px").css("width", "75%");
  						$("input:submit, .toolbarPlain a", ".formdiv" ).button();
  						
  						$("input:submit, .toolbarPlain a", ".formdiv" ).each (function() {
  							$(this).css("margin", "0.5em");
  							});
  						$(".courseSubmit").click(function(e) {
  							$("#courseForm").submit();
  						});
  						
  						
  						$("#enrollment_accordion").accordion();
  						$("input:text, input:password, select", ".formdiv" ).each (function() {
  							$(this).css("width", "100%"); 
  						});
  						$('.striped tr:even').addClass('alt');
  						$(".userRemoveLink, .assignmentRemoveLink").button({
            				icons: {
                				primary: "ui-icon-circle-close"
            				},
           					text: false
           				});
           				$(".userRemoveLink").click(function(e) {
    						e.preventDefault();
    						var targetUrl = $(this).attr("href");
							$("#dialog-confirm").dialog({
	     						 buttons : {
							        "Delete user" : function() {
							          window.location.href = targetUrl;
							        },
							        Cancel : function() {
							          $(this).dialog("close");
							        }
							      }
						    });
							$("#dialog-confirm").dialog("open");
   						});
   						$(".assignmentRemoveLink").click(function(e) {
    						e.preventDefault();
    						var targetUrl = $(this).attr("href");
							$("#dialog-confirm-assignment").dialog({
	     						 buttons : {
							        "Delete assignment" : function() {
							          window.location.href = targetUrl;
							        },
							        Cancel : function() {
							          $(this).dialog("close");
							        }
							      }
						    });
							$("#dialog-confirm-assignment").dialog("open");
   						});
           				
           				$( "#dialog-confirm, #dialog-confirm-assignment" ).dialog({
  							autoOpen: false,
							resizable: false,
							height:240,
							width:450,
							modal: true
						});
						
						
  					});
				</script>
				
				<title>SimOrg Course View</title>
			</head>
			<body>
				<div class="ui-widget top_toolbar" style="font-size:smaller"><span style="float:left" >Simorg Administration Dashboard</span><a class="logoutLink" href="{$rootUrl}admin/logout">logout</a></div>
             	
				 <form name="courseForm" id="courseForm" action="{$rootUrl}course/save/{/simorg/selected-course/course/@id}" method="post">
				 	<div id="primaryformdiv" class=" ui-widget ui-widget-content ui-corner-all">
						<h3 style="margin:0px;padding:.5em" class="ui-widget-header div-title">Course View</h3>
						<div class="formdiv ui-widget-content" style="padding-bottom:0px;margin-bottom:0px;padding-top:0px;margin-top:0px;">
							<fieldset>
							<div class="columnfieldlist">
							<ol>
								<li>
									<label for="name">Name</label>
									<input type="text" name="name" id="name" value="{/simorg/selected-course/course/name}" />
								</li>
								<li>
									<label for="semester">Instructor</label>
									<select name="instructor" id="instructor">
									<xsl:for-each select="/simorg/available-instructors/user">
										<xsl:choose>
										<xsl:when test="@id = /simorg/selected-course/course/user/@id">
											<option value="{@id}" selected="true"><xsl:value-of select="username" /></option>
										</xsl:when>
										<xsl:otherwise>
											<option value="{@id}"><xsl:value-of select="username"/></option>
										</xsl:otherwise>
										</xsl:choose>
									</xsl:for-each>
									</select>
								</li>
							</ol>
							</div>
							<div class="columnfieldlist">
							<ol>
								<li>
									<label for="semester">Semester</label>
									<input type="text" name="semester" id="semester" value="{/simorg/selected-course/course/semester}" />
								</li>
								<li>
									<label for="semester">Section</label>
									<input type="text" name="section" id="section" value="{/simorg/selected-course/course/section}" />
								</li>
								
							</ol>
							</div>
							</fieldset>
							
							<h3>Enrolled Students <span style="float:right;font-size:x-small"><a href="#enrollment">enroll students</a></span></h3>
							<table class="striped borderedTable ui-corner-all" style="margin-top:1em;width:100%">
		             			<tr>
		             			<th>&#160;</th>
		             			<th>Username</th>
		             			<th>Last Name</th>
		             			<th>First Name</th>
		             			</tr>
		             			<xsl:for-each select="simorg/selected-course/course/students/user">
		             			<tr>
		             				<td style="text-align:center"><a class="userRemoveLink" href="{$rootUrl}user/unenroll/{@id}?courseId={/simorg/selected-course/course/@id}">Remove User</a></td>
		             				<td style="text-align:center"><a href="{$rootUrl}user/view/{@id}"><xsl:value-of select="username"/></a></td>
		             				<td style="text-align:center"><xsl:value-of select="lastName"/></td>
		             				<td style="text-align:center"><xsl:value-of select="firstName"/></td>
		             			</tr>
		             			</xsl:for-each>
             				</table>
             				<xsl:for-each select="simorg/unenrollment_result">
								<p class="ui-state-highlight"><xsl:value-of select="message"/></p>
							</xsl:for-each>
             		
             				<h3>Assignments</h3>
             				<table class="striped borderedTable ui-corner-all" style="margin-top:1em;width:100%">
		             			<tr>
		             			<th>&#160;</th>
		             			<th>Assignment</th>
		             			<th>Assigned Date</th>
		             			<th>Due Date</th>
		             			</tr>
		             			<xsl:for-each select="/simorg/selected-course/course/assignments/assignment">
		             			<tr>
		             				<td style="text-align:center"><a class="assignmentRemoveLink" href="{$rootUrl}assignment/delete/{@id}?courseId={/simorg/selected-course/course/@id}">Remove Assignment</a></td>
		             				<td style="text-align:center"><a href="{$rootUrl}assignment/view/{@id}"><xsl:value-of select="title"/></a></td>
		             				<td style="text-align:center"><xsl:value-of select="assignedDate"/></td>
		             				<td style="text-align:center"><xsl:value-of select="dueDate"/></td>
		             			</tr>
		             			</xsl:for-each>
             				</table>
             				<xsl:for-each select="simorg/assignment_result">
								<p class="ui-state-highlight"><xsl:value-of select="message"/></p>
							</xsl:for-each>
             				
             		
							<div class="toolbarPlain" style="margin-top:0px">
								<a href="javascript:void(0);" class="courseSubmit">Save Course</a>
								<a href="{$rootUrl}assignment/new?courseId={simorg/selected-course/course/@id}" class="assignmentSubmit">New Assignment</a>
							</div>
						</div>
						
					</div>
					</form>
					
					
					
					
					<div id="primaryformdiv" class=" ui-widget ui-widget-content ui-corner-all">
						<h3 style="margin:0px;padding:.5em" class="ui-widget-header div-title">Enrollement</h3>
						<a name="enrollment"/>
						<div id="enrollment_accordion">
							<h3><a href="#">Batch Enrollment</a></h3>
							<div class="formdiv ui-widget-content" style="margin-bottom:0px;padding-bottom:0px" >
								<form  style="margin:0px;padding:0px" name="batchEnrollForm" action="{$rootUrl}user/batchenroll?courseId={simorg/selected-course/course/@id}" method="post">
					 				<label for="batchEnroll">Enter Last Name, First Name, Email address on each line:</label>
									<textarea id="batchEnroll" name="batchEnroll" rows="10" cols="30">
									</textarea>
									<p>(example:  Smith, Mary, msmith@ramapo.edu)</p>
									<input type="submit" value="Enroll All" />
								</form>
								<div >
									<xsl:for-each select="simorg/enrollment_result">
										<p class="ui-state-highlight"><xsl:value-of select="message"/></p>
									</xsl:for-each>
								</div>
							</div>
							<h3><a href="#">Single Enrollment</a></h3>
							<div class="formdiv ui-widget-content">
								<div style="float:right">
									<xsl:for-each select="simorg/enrollment_result">
										<p class="ui-state-highlight"><xsl:value-of select="message"/></p>
									</xsl:for-each>
								</div>
								<form style="margin:0px;padding:0px" name="enrollForm" action="{$rootUrl}user/enroll?courseId={simorg/selected-course/course/@id}" method="post">
					 				<fieldset>
					 				<ol>
										<li>
											<label for="email">Email</label>
											<input type="text" name="email" id="email"  value="{simorg/selected-user/user/email}" />
										</li>
										<li>
											<label for="firstName">First Name</label>
											<input type="text" name="firstName" id="firstName"  value="{simorg/selected-user/user/firstName}" />
										</li>
										<li>
											<label for="lastName">Last Name</label>
											<input type="text" name="lastName" id="lastName"  value="{simorg/selected-user/user/lastName}" />
										</li>
									</ol>
									</fieldset>
									<input type="submit" value="Enroll" />
								</form>
								
							</div>
							
						</div>
					</div>
					
					<form name="assignmentForm" id="assignmentForm" action="{$rootUrl}assignment/new?courseId={simorg/selected-course/course/@id}" method="post">
				 		<input type="hidden" name="courseId" id="courseId" value="{simorg/selected-course/course/@id}"/>
					</form>
					<div id="dialog-confirm" title="Remove User?">
						<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This will unenroll the student permanently. Are you sure?</p>
					</div>
					<div id="dialog-confirm-assignment" title="Remove Assignment?">
						<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This will delete the assignment permanently. Are you sure?</p>
					</div>
			</body>
		</html>
	</xsl:template>
	
</xsl:stylesheet>